<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>CL</title>
	<link rel="shortcut icon" href="logn.jpg">
	<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	<link rel="stylesheet" href="__ROOT__/__CSS__/login.css">
	<link rel="stylesheet" href="__ROOT__/__LAYUI__/css/layui.css">
</head>
<body style="background: url('__ROOT__/__IMG__/login_bg.png');background-repeat: no-repeat;background-size: 100% 100%;">
	<div class="head">
		<a href="javascript:history.back(-1)">取消</a>
	</div>
	<div class="login">
		<img src="__ROOT__/__IMG__/logn.jpg">
		<form method="post">
			<div class="text-input">
				<input type="text" name="member_name" id="member_name" placeholder="请输入名称">
			</div>
			<div class="text-input">
				<input type="text" name="mobile" id="mobile" placeholder="手机号" maxlength="11">
			</div>
			<div class="text-input">
				<input type="text" name="mobilecode" id="mobilecode" placeholder="验证码" maxlength="6">
				<a href="javascript:;" id="code">发送验证码</a>
			</div>
			<div class="text-input">
				<input type="password" name="pwd" id="pwd" placeholder="密码" minlength="6">
			</div>
			<div class="text-input">
				<button type="button" class="btn">注册</button>				
			</div>
		</form>
	</div>
</body>
</html>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="__ROOT__/__LAYUI__/layui.all.js"></script>
<script type="text/javascript">
$(function() {
	$('#code').click(function(){
		var member_name = $('#member_name').val();
		var mobile = $('#mobile').val();
		var pwd = $('#pwd').val();
		var mobilecode = $('#mobilecode').val();
		if (mobile == false) {
			layer.msg('请填写手机号！');
			return false;
		}else if(isPoneAvailable(mobile) == false){
			return false;
		}
		$.ajax({
			type: 'POST',
			url: "http://www.tp5.com/index/login/sendCaptcha",
			data: {member_name:member_name,mobile:mobile,type:1},
			dataType: 'JSON',
			success: function(result){
				if (result.stats) {
					layer.msg(result.msg);
				}else{
					layer.msg(result.msg);
				}
			}
		});
	});
	$('.btn').click(function(){
		var member_name = $('#member_name').val();
		var mobile = $('#mobile').val();
		var pwd = $('#pwd').val();
		var mobilecode = $('#mobilecode').val();
		var type = 1;
		if (member_name == false) {
			layer.msg('请填用户名称！');
			return false;
		}else if (mobile == false) {
			layer.msg('请填手机号码！');
			return false;
		}else if (mobilecode == false) {
			layer.msg('请填验证码！');
			return false;
		}else if (pwd == false) {
			layer.msg('请填用户密码！');
			return false;
		}
		$.ajax({
			type: 'POST',
			url: "http://www.tp5.com/index/login/register",
			data: {member_name:member_name,mobile:mobile,pwd:pwd,mobilecode:mobilecode,type:type},
			dataType: 'JSON',
			success: function(result){
				if (result.stats) {
					layer.msg(result.msg);
				}else{
					layer.msg(result.msg);
				}
			}
		})
	})
})
function isPoneAvailable(data) {
	var reg = /^(13[0-9]|15[012356789]|17[0-9]|18[0-9]|14[57])[0-9]{8}$/;
	if (!reg.test(data)) {
		layer.msg('抱歉，请输入正确的手机号!');
		return false;
	} else {
		return data;
	}
}
</script>